package cn.edu.zjut.mina.po;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Table(name="t_user")
@Entity
public class User {
	private Integer autoid;
	private String uname;
	private String password;
	private String ip;
	private Every every;
	@GeneratedValue
	@Id
	public Integer getAutoid() {
		return autoid;
	}
	public void setAutoid(Integer autoid) {
		this.autoid = autoid;
	}
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@Transient
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	
	@ManyToOne(cascade = CascadeType.PERSIST, optional=true,fetch = FetchType.EAGER)
	@JoinColumn(name="every_id", referencedColumnName="autoid")
	public Every getEvery() {
		return every;
	}
	public void setEvery(Every every) {
		this.every = every;
	}
	@Override
	public String toString() {
		return "User [autoid=" + autoid + ", uname=" + uname + ", password=" + password + ", ip=" + ip + "]";
	}
	
}
